
import { postAdminOperateGetSize } from "@/api"
import CryptoJS from "crypto-js";
import Clipboard from "clipboard";
export default {

    data() {
        return {
        }
    },
    created() {
    },
    activated() { },
    methods: {
        async onCopy(e) {
            var clipboard = new Clipboard(e);
            clipboard.on("success", (e) => {
                this.$message.success("复制成功")
                clipboard.destroy();
            });

            clipboard.on("error", (e) => {
                // 不支持复制

                console.log("该浏览器不支持自动复制"); // 释放内存

                clipboard.destroy();
            });
        },
        async GetSizeList(data) {
            let res = await postAdminOperateGetSize(data)
            console.log("list", res);
            return res.data
        },
        // 加密
        encrypt(word) {
            const key = CryptoJS.enc.Utf8.parse("SHISANYUABCDEF16"); //十六位十六进制数作为密钥
            const iv = CryptoJS.enc.Utf8.parse("61FEDCBASHISANYU"); //十六位十六进制数作为密钥偏移量
            let srcs = CryptoJS.enc.Utf8.parse(word);
            let encrypted = CryptoJS.AES.encrypt(srcs, key, {
                iv: iv,
                mode: CryptoJS.mode.CBC,
                padding: CryptoJS.pad.Pkcs7,
            });
            return encrypted.ciphertext.toString().toUpperCase();
        },
        // 解密
        decrypt(word) {
            const key = CryptoJS.enc.Utf8.parse("SHISANYUABCDEF16"); //十六位十六进制数作为密钥
            const iv = CryptoJS.enc.Utf8.parse("61FEDCBASHISANYU"); //十六位十六进制数作为密钥偏移量
            let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
            let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
            let decrypt = CryptoJS.AES.decrypt(srcs, key, {
                iv: iv,
                mode: CryptoJS.mode.CBC,
                padding: CryptoJS.pad.Pkcs7,
            });
            let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
            return decryptedStr.toString();
        },
    }
}